#-*- coding: utf-8 -*-
# 删除已经使用过的视频文件

import os

def get_files(folder):
    try:
        # Get list of files in folder
        file_list = os.listdir(folder)
    except:
        file_list = []  
    return [
        # os.path.join(folder, f)
        f
        for f in file_list
        if os.path.isfile(os.path.join(folder, f))
        and f.lower().endswith((".mp4"))
    ]

def delete_files(folder_delete, folder_refer):
    refer_files = get_files(folder_refer)
    delete_file_names = get_files(folder_delete)
    
    for f in delete_file_names:
        if "ai" + f in refer_files:
           os.remove(os.path.join(folder_delete, f))

if __name__ == "__main__":
    # print(get_files("D:\音乐号项目\素材\视频"))
    delete_files("D:\音乐号项目\素材\视频", "D:\音乐号项目\素材\视频\AI_DtuQlvhILQ")